package com.itheima.controller;

import com.itheima.service.mongo.UserLocationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/userLocation")
public class UserLocationController {

    @Autowired
    private UserLocationService userLocationService;

    @PostMapping("/save")
    public void save(Long userId, Double longitude, Double latitude, String address) {
        userLocationService.save(userId,longitude,latitude,address);
    }

    @GetMapping("/findNearUserIdList")
    public List<Long> findNearUserIdList(Long userId, Long distance) {
        return userLocationService.findNearUserIdList(userId, distance);
    }
}
